package com.richpencil.utils;

import java.util.Random;

public class RandomUtil {

	/*
	 * 生成九位英文数字随机用户名
	 */
	public static StringBuffer GetRandomUserName() {
		String chars = "abcdefghjklmnpqrstuvwxyz";
		Random random = new Random();
		// 第一位数字
		String one = String.valueOf(random.nextInt(10));
		String tow = String.valueOf(chars.charAt((int) (Math.random() * 24)));
		String three = String.valueOf(chars.charAt((int) (Math.random() * 24)));
		String four = String.valueOf(random.nextInt(10));
		String five = String.valueOf(chars.charAt((int) (Math.random() * 24)));
		String six = String.valueOf(random.nextInt(10));
		String seven = String.valueOf(chars.charAt((int) (Math.random() * 24)));
		String eight = String.valueOf(random.nextInt(10));
		String nine = String.valueOf(random.nextInt(10));

		StringBuffer RandomUserName = new StringBuffer();
		RandomUserName.append(one);
		RandomUserName.append(tow);
		RandomUserName.append(three);
		RandomUserName.append(four);
		RandomUserName.append(five);
		RandomUserName.append(six);
		RandomUserName.append(seven);
		RandomUserName.append(eight);
		RandomUserName.append(nine);
		return RandomUserName;
	}
	public static int  getRandomInt() throws InterruptedException {
		
		 Thread.sleep(1);;
		 Random rand = new Random(System.currentTimeMillis());
		 int number=rand.nextInt(5);
		 return (number+1)*1000;
		 
	}
	
	public static int  getRandom(int value) throws InterruptedException {
		
		 Thread.sleep(1);;
		 Random rand = new Random(System.currentTimeMillis());
		 int number=rand.nextInt(value);
		 return number;
		 
	}
	
	public static void SleepRandomSecond()
	{
		try {
			int second=getRandomInt();
			Thread.sleep(second);
		} catch (InterruptedException e) {
			
		}
	}
}
